package com.woniu.dating.mapper;

import com.woniu.dating.pojo.DatingDynamic;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.dating.vo.DynamicVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 玖柒
 * @since 2023-05-20
 */
public interface DatingDynamicMapper extends BaseMapper<DatingDynamic> {

    /**
     * 个人动态
     * @param userId
     * @return
     */
    @Select("SELECT dd.`user_id`, dd.`dynamic`, dd.`create_time`, dh.nickname, dh.avatar FROM t_dating_dynamic dd INNER JOIN t_dating_hobby dh ON dd.`user_id` = dh.user_id  WHERE dd.`user_id` = 1 ORDER BY dd.`create_time` DESC")
    @ResultType(DynamicVO.class)
    List<DynamicVO> getgetDatingDynamic(Integer userId);

    /**
     * 删除动态
     * @param userId
     * @param dynamicId
     */
    @Select("delete from t_dating_dynamic where user_id = #{userId} and dynamic_id = #{dynamicId}")
    void deleteDynamic(@Param("userId") Integer userId, @Param("dynamicId") Integer dynamicId);


    /**
     * 动态圈
     * @param userId
     * @return
     */
    @Select("SELECT dd.`user_id`, dd.`dynamic`, dd.`create_time`, dh.nickname, dh.avatar FROM t_dating_dynamic dd INNER JOIN t_dating_hobby dh ON dd.`user_id` = dh.user_id INNER JOIN t_dating_concern dc ON dc.`user_id` = dd.`user_id` \n" +
            "  WHERE dc.`current_id` = 1 AND dd.`user_id` = dc.`user_id` ORDER BY dd.`create_time` DESC")
    @ResultType(DynamicVO.class)
    List<DynamicVO> dynamicCircle(Integer userId);
}
